Skip to content

mcp: add per session list changed notifications - #1511

Merged
guglielmo-san merged 4 commits into
mainfrom
serob/add-per-session-list-changed-notifications
Nov 9, 2026
Merged

guglielmo-san merged 4 commits into
mainfrom
serob/add-per-session-list-changed-notifications

Conversation

@nahapetyan-serob

Copy link
Copy Markdown
Contributor

fixes #1480

@chrikrah chrikrah left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nahapetyan-serob nothing here blocks a merge from my side. With notifyListChanged stubbed to return nil, both new tests fail.

non-blocking: deleting server.go:1749 (ctx := context.WithValue(ctx, idContextKey{}, id)) keeps all of ./mcp green. Only Streamable HTTP routes by that ID (streamable.go:2093), and the tests use in-memory transports. Without it, a notify from inside a tool handler would go out on the tool call's stream, not the listen. A Streamable HTTP test that notifies from a handler would pin it.

$ go test ./... -count=1        # 4325744, go1.27.3 darwin/arm64, GOTOOLCHAIN=local
ok  	github.com/modelcontextprotocol/go-sdk/mcp	39.043s
(all 14 packages ok; go vet ./mcp clean)

$ (notifyListChanged returning nil first) go test ./mcp -run TestNotifyListChanged -count=1
--- FAIL: TestNotifyListChanged_OnlyChosenSession (15.01s)    # tool, prompt, resource
--- FAIL: TestNotifyListChanged_WhenSent (5.11s)               # legacy

$ (server.go:1749 replaced by `_ = id`) go test ./mcp -count=1
ok  	github.com/modelcontextprotocol/go-sdk/mcp	36.084s
# not run: a real HTTP client against a listen stream

Can that test go in with this PR?

Comment thread mcp/server.go Resolved
…thub.com:modelcontextprotocol/go-sdk into serob/add-per-session-list-changed-notifications
@nahapetyan-serob

Copy link
Copy Markdown
Contributor Author

Thanks @chrikrah, added TestNotifyListChanged_StreamableStateless

@guglielmo-san
guglielmo-san merged commit 0e849cb into main Nov 9, 2026
10 checks passed
@guglielmo-san
guglielmo-san deleted the serob/add-per-session-list-changed-notifications branch November 9, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcp: list_changed can only be broadcast; a server cannot notify one session (2026-07-28 subscriptions/listen)

3 participants